//
// Created by denglibin on 2021/6/1.
//
#include "fun.h"
#include <SDL_image.h>
/**
 * 根据图片获取纹理
 * @param img
 * @param renderer
 * @return
 */
SDL_Texture * createTexture(const char* img, SDL_Renderer* renderer){
    SDL_Surface  * surface = IMG_Load(img);
    if (surface == NULL){
        SDL_Log("Can not load image %s\n", SDL_GetError());
        exit(1);
    }
    SDL_Texture* texture  = SDL_CreateTextureFromSurface(renderer, surface);
    if (texture == NULL){
        SDL_Log("Can not create texture %s\n", SDL_GetError());
        exit(1);
    }
    //获取宽高
    //SDL_QueryTexture(texture, NULL, NULL, &w, &h);
    SDL_FreeSurface(surface);//清理
    return texture;
}